/*
	使用Interface对象逐行读取文件
*/

var readline = require('readline');

var fs = require('fs');

var file = fs.createReadStream('./message.txt');
var out = fs.createWriteStream('./anotherMessage.txt');

var index = 1;

out.write("line" + index.toString() + ":");
index += 1;

var r1 = readline.createInterface({
	input: file,
	output: out,
	terminal: true
});

r1.on('line', function(line) {
	out.write("line" + index.toString() + ":");
	index += 1;
});